<template>
	<page-meta>
	    <navigation-bar
	      title="手机验证"
	      front-color="#ffffff"
	      background-color="#046ef6"
	    />
	  </page-meta>
	<view>
			<!-- #ifdef APP-PLUS || H5-->
			<view v-if="platform === 'ios' && !isNvue" class="uni-form-item uni-column">
				<view class="uni-input-wrapper"><input class="uni-input" type="number" placeholder="请输入手机号码" @focus="onFocus" @blur="onBlur" v-model="query.phone" /></view>
			</view>
			<view class="uni-form-item uni-column" v-else>
				<view class="uni-input-wrapper"><input class="uni-input" type="number"  placeholder="请输入手机号码" v-model="query.phone" /></view>
			</view>
			<!-- #endif -->
			<button
				@tap="sub"
				style="width: calc(100% - 20px);display: block;margin: 0px 10px;margin-top: 60px;background: #046ef6;border-radius: 15px;color: #fff;"
				type="default"
			>
				下一步
			</button>
	</view>
</template>

<script>
export default {
	data() {
		return {
			platform: '',
			isNvue: false,
			query: {
				phone: '',
				pass: ''
			}
		};
	},
	onLoad() {
		this.platform = uni.getSystemInfoSync().platform;
		// #ifdef APP-PLUS-NVUE
		this.isNvue = true;
		// #endif
	},
	methods: {
		onFocus() {
			// #ifdef APP-PLUS
			this.$mp.page.$getAppWebview().setStyle({
				softinputNavBar: 'none'
			});
			// #endif
		},
		onBlur() {
			// #ifdef APP-PLUS
			this.$mp.page.$getAppWebview().setStyle({
				softinputNavBar: 'auto'
			});
			// #endif
		},

		sub() {
			var _this = this;
			if (!this.query.phone) {
				uni.showToast({
					title: '手机号码不能为空!',
					icon: 'none'
					// position:'top'
				});
			} else {
				if (!/^1[3456789]\d{9}$/.test(this.query.phone)) {
					uni.showToast({
						title: '手机号码格式错误!',
						icon: 'none'
						// position:'top'
					});
					return;
				}
				uni.request({
					url: this.$store.state.url + '/api/shequuser/login/isexituser', //检查账号是否已注册
					method: 'POST',
					data:JSON.stringify({
						"faccount": _this.query.phone,
						  "fpwd": "string",
						  "fcode": "string"
					}),
					success: res => {
						res = res.data;
						if (res.code == 200) {
							uni.request({
								url: _this.$store.state.url + '/api/shequuser/login/getcode?phone=' + _this.query.phone, //获取验证码
								method: 'POST',
								success: ress => {
									ress = ress.data;
									if (ress.code == 200) {
										uni.navigateTo({
											url: '/pages/login/relogin1?phone=' + _this.query.phone
										});
									}else{
										uni.showToast({
											title: ress.msgs,
											icon: 'none'
											// position:'top'
										});
									}
								},
								fail: res => {
									console.log(res);
								}
							});
						}else{
							uni.showToast({
								title: res.msgs,
								icon: 'none'
								// position:'top'
							});
						}
					},
					fail: res => {
						console.log(res);
					}
				});
				
			}
		}
	}
};
</script>

<style scoped>
	.uni-input:hover {
		border-bottom: 1px solid #007aff;
	}
.Toolssss,
.check {
	padding: 8px 12px;
	font-size: 14px;
}
.Toolssss > uni-text {
	float: left;
}

.Toolssss > uni-navigator {
	float: right;
}
.container {
	padding: 10upx;
}
.check {
	display: flex;
	flex-direction: row; /*这里可以不写，flex布局默认方向横向即row*/
	justify-content: center;
	align-items: center;
	margin-top: 15px;
}
.check lable {
	font-size: 15px;
}

.check lable span {
	width: 18px;
	height: 18px;
	display: block;
	float: left;
	background: #ccc;
	border-radius: 50%;
	margin-right: 5px;
	text-align: center;
	color: #fff;
}
.check lable span.active {
	background: #046ef6;
}
.check lable span.active::before {
	content: '✓';
	font-size: 12px;
}
.check > uni-navigator {
	color: #168dea;
	font-size: 15px;
}
.nvue-page-root {
	background-color: #f8f8f8;
	padding-bottom: 20px;
}

.page-title {
	/* #ifndef APP-NVUE */
	display: flex;
	/* #endif */
	flex-direction: row;
	justify-content: center;
	align-items: center;
	padding: 35rpx;
}

.page-title__wrapper {
	padding: 0px 20px;
	border-bottom-color: #d8d8d8;
	border-bottom-width: 1px;
}

.page-title__text {
	font-size: 16px;
	height: 48px;
	line-height: 48px;
	color: #bebebe;
}

.title {
	padding: 0px 13px;
}
.uni-form-item {
	margin-top: 20px;
}
.uni-form-item__title {
	font-size: 16px;
	line-height: 24px;
}

.uni-input-wrapper {
	/* #ifndef APP-NVUE */
	display: flex;
	/* #endif */
	padding: 2px 13px;
	flex-direction: row;
	flex-wrap: nowrap;
	width: auto;
	background-color: #ffffff;
}

.uni-input {
	height: 45px;
	line-height: 45px;
	font-size: 15px;
	padding: 0px;
	flex: 1;
	background-color: #ffffff;
	border-bottom: 1px solid #eee;
}

.uni-icon {
	font-family: uniicons;
	font-size: 24px;
	font-weight: normal;
	font-style: normal;
	width: 24px;
	height: 24px;
	line-height: 24px;
	color: #999999;
}

.uni-eye-active {
	color: #007aff;
}
</style>
